package com.infore.common.response;


import com.infore.common.enums.BaseError;
import com.infore.common.enums.ErrorCode;

/**
 * @author lijianhua
 * @Date 2022-11-29 11:11
 */
public class ApiResponseBuilder {

    public static ApiResponse buildOk(){
        return buildError(BaseError.OK_KEY_VALUE);
    }

    public static ApiResponse buildError(){
        return buildError(BaseError.BI_INNER_ERROR);
    }

    public static ApiResponse buildError(ErrorCode error) {
        String code = error.getCode();
        String msg=error.getMsg();
        return new ApiResponse(false, code,msg);
    }

    public static ApiEntityResponse buildEntityError(ErrorCode error){
        String code = error.getCode();
        String msg=error.getMsg();
        return ApiEntityResponse.error(code,msg);
    }

    public static ApiListResponse buildListError(ErrorCode error){
        String code = error.getCode();
        String msg=error.getMsg();
        return ApiListResponse.error(code,msg);
    }

}
